# -*- coding:utf8 -*- #
# -----------------------------------------------------------------------------------
# ProjectName:   property-ui-auto-test
# FileName:     runner
# Author:      
# Datetime:    2022/5/2 16:08
# Description：
# -----------------------------------------------------------------------------------
import unittest
from mfyreport import TestRunner
from common.util.confUtil.configUtil import Config
from common.util.timeUtil.timeUtil import get_now_time


class Smalleel:
    @staticmethod
    def smalleel_run():
        """
        这是测试
        :return:
        """
        conf = Config()
        # 获取用例模块的地址
        casePath = conf.get_case_path()
        # 获取报告地址
        reporPath = conf.get_report_path()
        # 加载test_login.py用例
        suite = unittest.defaultTestLoader.discover(casePath, pattern=conf.get_runner_config("pattern"))
        # 给文件保存的时候加上时间
        # 运行测试用例,并且生成报告
        runTest = TestRunner(suite, filename=conf.get_runner_config("filename").format(get_now_time(3)),
                              report_dir=reporPath, title=conf.get_runner_config("title"),
                              tester=conf.get_runner_config("tester"),
                              desc=conf.get_runner_config("desc"), templates=int(conf.get_runner_config("templates")))
        runTest.run()
        # 发送邮件
        # 邮件接收者
        # runTest.send_email(host=conf.get_email_config("host"), port=int(conf.get_email_config("port")),
        #                    user=conf.get_email_config("user"), password=conf.get_email_config("password"),
        #                    to_addrs=conf.get_email_addr("all"))


if __name__ == '__main__':
    Smalleel().smalleel_run()

